<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/css/common.css" />
		<link rel="stylesheet" type="text/css" href="/js/flatpickr.min.css" />
		<link rel="stylesheet" type="text/css" href="/bootstrap-3.3.7/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="/dialog/css/dialog.css" />
		<link rel="stylesheet" type="text/css" href="/css/font-awesome.css" />
	</head>

	<body>
		<!--顶部导航 -->
		<nav class="topNavItemBox">
			<div id="ItemBox">
				<div class="title">肉品溯源管理系统</div>
			</div>
		</nav>
		<!-- 左侧导航 -->
		<#include "left.ftl"/>

        <!--检疫查询 -->

		<div class="page_main">
			<h3>疫苗库存管理</h3><span class="add_link"><a href="vaccineAdd.ftl">新增疫苗库存信息></a></span>
			<div class="page_content">
				<h4>疫苗库存查询</h4>
				<br /><br />
				<form id="vaccineInfo_query" method="post" action="VaccineAction_getVaccineStockByCondition">
					<label style="width:100px">疫苗名称</label><input type="text" name="vaccineName" class="commonInputtext" /><span></span>
					<label style="width:100px">疫苗类型</label><input type="text" name="vaccineType" class="commonInputtext" /><span></span>
					<label style="width:120px">疫苗供应商</label><input type="text" name="compName" class="commonInputtext" />
					<input type="submit" value="查询" style="display: inline-block; margin-left: 30px;" />
					<!--<span class="newQuarantine"> <a hrquarantineInfo_add.ftlhtml">新增检疫情况></a></span>-->
				</form>
				<div>
					<table id="vaccineInfo_table" class="table" width="100%">
						<thead>
							<tr>
								<th>
								<!-- <input id="checkall" type="checkbox" /> -->
								</th>
								<th width="100">疫苗名称</th>
								<th width="100">疫苗类型</th>
								<th width="100">总量</th>
								<th width="100">已用量</th>
								<th width="120">库存量</th>
								<th width="120">企业名称</th>
								<th width="120">企业负责人</th>
								<th width="120">企业联系方式</th>
								<th width="120">描述</th>
								<th width="120">最近一次操作</th>
								<th width="120"></th>
							</tr>
						</thead>
						<tbody>
							<tr id="no_data">
								<td></td>
								<td>暂无数据</td>
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<!--<input type="button" id="deleteAllchoice" value="删除所选">-->
				<div id="barcon" name="barcon" style="margin-left: 200px;font-size:10px"></div>
			</div>
			<div class="footer">
				<div class="footer_lineone">
					<span id="logo"></span>肉品溯源管理系统 
					<span class="footer_lineoneSpan"><a href="aboutus.html">关于我们</a></span>
					<span class="footer_lineoneSpan"><a target="_blank" href="http://www.cfsiw.com/">食品安全信息</a></span> 
					<span class="footer_lineoneSpan"><a href="suggestionAdd.ftl">联系我们</a></span>
				</div>
				<div class="footer_linetwo">
					 &copy;2017广东技术师范学院
				</div>
			</div>
		</div>

		<script src="/js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/google-maps.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/jquery.form.js"></script>
		<script src="/dialog/js/dialog.js"></script>
		<script src="/js/flatpickr.js"></script>
		<script src="/js/jquery.validate.min.js"></script>
		<script src="/js/messages_zh.min.js"></script>
		
		<script src="/js/common.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" charset="UTF-8">
			$(function() {
				//初始化侧边栏
				$(".vertical-nav").verticalnav({
					speed: 400,
					align: "left"
				});

				var re_data; //每次传过来的数据
				//查询
				$("#vaccineInfo_query").ajaxForm(function(data) {
					console.log(data);
					re_data = data;
					$("#vaccineInfo_table tbody tr").remove();
					for(var i = 0; i < data.length; i++) {
						var no = i+1;
						var tb = $("#vaccineInfo_table tbody");
						var td1 = '<td>'+ no +'</td>';
						var td2 = '<td>' + data[i].vaccineName + '</td>';
						var td3 = '<td>' + data[i].vaccineType + '</td>';
						var td4 = '<td>' + data[i].vaccineTotal + '</td>';
						var td5 = '<td>' + data[i].outQuantity + '</td>';
						var td6 = '<td>' + data[i].numInStore + '</td>';
						var td7 = '<td>' + data[i].compName + '</td>';
						var td8 = '<td>' + data[i].contacts + '</td>';
						var td9 = '<td>' + data[i].contactsPhone + '</td>';
						var td10 = '<td>' + data[i].remark + '</td>';
						var td11 = '<td>' + data[i].renewDate.replace("T", " ") + '</td>';
						var td12 = '<td><input type="button" onclick="updateData(' + i + ')" class="change" value="更改" style="padding:0 5px"/></td>'
						var tr_add = '<tr id="vaccineInfo_row' + data[i].vaccineId + '">' + td1 + td2 + td3 + td4 + td5 + td6 + td7 + td8 + td9 + td10 + td11 + td12 + '</tr>'
						tb.append(tr_add);
						
					}
					$("#no_data").remove();
					goPage(1,4,"vaccineInfo_table");
				});


				//更改

				updateData = function(i) {
					var row0 = '<form id="vaccineInfo_updateform" action="VaccineAction_updateVaccine" method="post"><ul class="changePage450">'
					var row1 = '<li><label class="labelBeforinput">疫苗名称</label><input name="vaccineName" require class="bigInputtext" type="text" value="' + re_data[i].vaccineName + '" /></li>';
					var row2 = '<li><label class="labelBeforinput">疫苗类型</label><input name="vaccineType" require class="bigInputtext" type="text" value="' + re_data[i].vaccineType + '" /></li>';
					var row3 = '<li><label class="labelBeforinput">物品描述</label><input name="remark" require class="bigInputtext" type="text" value="' + re_data[i].remark + '" /></li></ul>';
					var row4 = '<input type="hidden" name="vaccineId" value="' + re_data[i].vaccineId + '" />';
					var row5 = '<input type="hidden" name="compName" value="' + re_data[i].compName + '" />';
					var row6 = '<input type="hidden" name="compId" value="' + re_data[i].compId + '" />';
					var row7 = '<input type="hidden" name="numInStore" value="' + re_data[i].numInStore + '" />';
					var row8 = '<input type="hidden" name="contacts" value="' + re_data[i].contacts + '" />';
					var row9 = '<input type="hidden" name="contactsPhone" value="' + re_data[i].contactsPhone + '" />';
					var row10 = '<input type="hidden" name="outQuantity" value="' + re_data[i].outQuantity + '" />';
					var row11 = '<input type="hidden" name="vaccineTotal" value="' + re_data[i].vaccineTotal + '" />';
					var row12 = '<input type="hidden" name="manufactoryId" value="' + re_data[i].manufactoryId + '" />';
					var row13 = '</form>'
					var str = row0 + row1 + row2 + row3 + row4 + row5 + row6 + row7 + row8 + row9 + row10 + row11 + row12 + row13;
					//console.log($("#vaccineInfo_table"));

					$.dialog({
						type: 'confirm',
						titleText: '更改数据',
						contentHtml: str,
						onClickOk: function() {
							$("#vaccineInfo_updateform").ajaxSubmit({
								type: 'post',
								success: function(data) {
									console.log(data);
									$.dialog({
										type: 'info',
										contentHtml: '<img class="info-icon" src="dialog/images/icon/success.png" alt="'+data.success+'" /><p class="info-text">'+data.success+'</p>',
										autoClose: 2000
									});
									
									var row = $("#vaccineInfo_row" + data.vaccineInfor.vaccineId);
									//console.log(data);
									row.find("td").eq(1).text(data.vaccineInfor.vaccineName);
									row.find("td").eq(2).text(data.vaccineInfor.vaccineType);
									row.find("td").eq(3).text(data.vaccineInfor.vaccineTotal);
									row.find("td").eq(4).text(data.vaccineInfor.outQuantity);
									row.find("td").eq(5).text(data.vaccineInfor.numInStore);
									row.find("td").eq(6).text(data.vaccineInfor.compName);
									row.find("td").eq(7).text(data.vaccineInfor.contacts);
									row.find("td").eq(8).text(data.vaccineInfor.contactsPhone);
									row.find("td").eq(9).text(data.vaccineInfor.remark);
									row.find("td").eq(10).text(data.vaccineInfor.renewDate.replace("T", " "));

									re_data[i] = data.vaccineInfor;

								}

							});
						}

					});
					//时间控制器
					$("vaccineInfo_updateform").validate();
					$("input[name='inspectTime']").flatpickr();
				}

			});
		</script>

	</body>

</html>